---
title: Plain text to PDF
summary: Paginate plain text at a fixed line count per page and render each block with fixed typography.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-17
library: PdfAPI.SyncFusionCore
reference_type: package
operation_id: OP-SFC-006
trigger: Called by ConverterFactory for the txt extension
---

# Plain text to PDF

Converts a plain-text stream to PDF bytes by splitting the text into fixed-size line blocks and drawing each block onto its own page with fixed typography. The PDF/A conformance level is not applied here — the produced PDF is resubmitted through [Convert a source document to PDF](convert-source-document-to-pdf.md) for that.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-SFC-006 |
| **Trigger** | Called by [Execute a single conversion (converter template)](execute-single-conversion.md) via `TxtConverter.ConvertItem`, dispatched from [Convert a source document to PDF](convert-source-document-to-pdf.md) for `txt` |
| **Inputs** | Source `Stream`, `ConvertRequest` |
| **Outputs** | PDF `byte[]` |
| **Primary components** | `TxtConverter.ConvertItem`, `TxtConverter.LinesPerPage` |
| **Entry point** | `PdfApi.SyncFusionCore\Convert\TxtConverter.cs` |

## Steps

1. Read the whole stream as ASCII text ([BR-SFC-012](../business-rules.md#br-sfc-012-ascii-only-source-text-reading)).
2. Split the text on `Environment.NewLine` (`StringSplitOptions.None`) into a line array.
3. Create an unconstrained `PdfDocument` — the PDF/A conformance level is **not** applied here
   ([BR-SFC-004](../business-rules.md#br-sfc-004-text-converted-via-intermediate-pdf)); the PDF/A upgrade happens when [Convert a source document to PDF](convert-source-document-to-pdf.md) step 4 recursively resubmits the produced PDF.
4. Loop: take `LinesPerPage` (default 40) lines starting at the current offset, joined with `\r\n`
   via `SAIF.Common.Extensions.ToStringAll` ([BR-SFC-014](../business-rules.md#br-sfc-014-fixed-40-lines-per-page-pagination)).
5. Add a page, create a 12 pt `PdfStandardFont(Helvetica)`, and a `PdfStringFormat` with `Justify`
   alignment, `Top` line alignment and a 15 pt paragraph indent; draw the block into the page client rectangle ([BR-SFC-015](../business-rules.md#br-sfc-015-fixed-text-typography)).
6. Advance the offset by `LinesPerPage`; stop when the offset reaches the line count ([BR-SFC-014](../business-rules.md#br-sfc-014-fixed-40-lines-per-page-pagination)).
7. Save to a `MemoryStream`, close the document, and return the bytes.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start(["ConvertItem called<br>with stream, request"]) --> Read[Read stream as ASCII text]
	Read --> Split["Split into lines on<br>Environment.NewLine"]
	Split --> Create["Create unconstrained<br>PdfDocument"]
	Create --> Loop{"Offset < line count?"}
	Loop -->|Yes| TakeBlock["Take LinesPerPage lines<br>from current offset"]
	TakeBlock --> Draw["Add page, draw block with<br>12pt Helvetica, justified,<br>15pt indent"]
	Draw --> Advance["Advance offset<br>by LinesPerPage"]
	Advance --> Loop
	Loop -->|No| Save["Save to MemoryStream,<br>close document"]
	Save --> Return([Return PDF bytes])
```

## Failure and edge-case behavior

- Any Syncfusion conversion failure surfaces as an exception, which is caught by
  [Execute a single conversion (converter template)](execute-single-conversion.md) and turned into a failed `PdfResult` rather than propagated here.
- `LinesPerPage` is a public instance field, so a caller with a direct `TxtConverter` reference can
  override the default 40-line pagination.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `PdfApi.SyncFusionCore\Convert\TxtConverter.cs`
